﻿angular.module('resources.collectionProxy', []);
angular.module('resources.collectionProxy').factory('collectionProxy', ['rresource', function (rresource) {
    var factory = rresource('collection');

    factory.forPaging = function (index, itemCount, successcb, failedcb) {

        var itemspage = (index - 1) * 10;
        var filterStr = "$top=" + itemCount + "&$skip=" + itemspage;

        return factory.odataQuery(filterStr, successcb, failedcb);

    };

    //        Resource.getCustomerByQuery = function (query) {
    //            var defer = $q.defer();

    //            $http({
    //                data: JSON.stringify(query),
    //                url: serviceBase + 'GetCustomerByQuery',
    //                method: 'POST'
    //            }).success(function (response) {
    //                defer.resolve({ data: response });
    //            }).error(function (ex) {
    //                alert('error');
    //            });
    //            return defer.promise;
    //        }

    //        Resource.getCustomerScore = function (customerCode) {
    //            var defer = $q.defer();

    //            $http.get(serviceBase + 'GetCustomerScore', { params: { customerCode: customerCode} }).then(function (response) {
    //                defer.resolve(response);
    //            });
    //            return defer.promise;
    //        }

    return factory;
} ]);
